var pagesize = 15;
var pageNow = 1;
var pagecount = 0;
var count = 0;
var category = '';

$(function() {

	if (typeof location.search) {
		var value = location.search;
		//alert(encodeURI(value.split('=')[1]));
		category = decodeURI(value.split('=')[1]);

	}else{
		alert('参数传递错误！');
	}


	//得到数据表格
	ajax('../InformationAction', 'pageNow=1&category=' + category);

	//搜索函数
	$("#a_search")
	.click(
			function() {

				var value = $("#searchtext").val();
				if (Trim(value) != "") {
					ajax('../InformationAction', 'pageNow='
							+ pageNow + "&target=" + value
							+ "&category=" + category);
				} else {
					alert("没有输入关键字!");
				}
				//将选择框复原
				$("#dselect").children(":first").attr("selected",
				"true");
			});
	//下拉框变动
	$("#dselect")
	.change(
			function() {

				var department = $(".select_:selected").val();
				if (department == "#") {
					department = "全部";
				}
				ajax('../InformationAction', 'pageNow=' + pageNow
						+ "&target=" + department + "&category="
						+ category);
				$("#searchtext").val("");
			});
});

//删除指定的一条信息
function delone(e) {
	var value = e;
	ajax_post('../DelSingleMessage', "value=" + value, function(data) {
		if (data == true) {
			//alert("删除成功");
			//location.reload();
			//删除该行
			$('#id_' + value).remove();
		} else {
			alert("删除失败");
		}

	});

}
//删除所有选择的信息
function deleteall() {
	var len = $("input:checkbox:checked").length;
	var value = "";
	var array = [];
	for ( var i = 0; i < len; i++) {
		var val = $("input:checkbox:checked:eq(" + i + ")").val();
		array.push(val); //保存id
		if (i == (len - 1)) {
			value += val;
		} else {
			value += val + ",";
		}
	}
	if (value != "") {
		ajax_post('../DelSelectedMessage', "value=" + value,
				function(data) {
			if (data == true) {
				for ( var x = 0; x < array.length; x++) {
					//依次删除行
					$('#id_' + array[x]).remove();
				}
			} else {
				alert("删除失败");
			}
		});
	} else {
		alert("请选中目标");
	}
}


